package com.example.cachedemo;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public final class PhotoViewHolder extends RecyclerView.ViewHolder {
    private ImageView photoImageView;
    private TextView nameTextView;

    public PhotoViewHolder(@NonNull View itemView) {
        super(itemView);

        photoImageView = (ImageView)itemView.findViewById(R.id.image_item);
        nameTextView = (TextView)itemView.findViewById(R.id.text_item);
    }

    public void setName(String name) {
        if (name != null) {
            nameTextView.setText(name);
        }
    }

    public void setImage(Bitmap bitmap) {
        if (bitmap != null) {
            photoImageView.setImageBitmap(bitmap);
        }
    }

    public ImageView getPhotoImageView() {
        return photoImageView;
    }
}
